//
//  DetailViewController.m
//  彩票
//
//  Created by 冀柳冲 on 2017/8/15.
//  Copyright © 2017年 冀柳冲. All rights reserved.
//

#import "DetailViewController.h"

@interface DetailViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>

@end


//http://mapi.91alli.com/service.json?authedUserId=8201711152338949&service=PURCHASE_ORDER_QUERY_BY_PURCHASE_NO&purchaseNo=67012017120606110933&queryEntries=1&loginKey=LOGIN_20171205220734

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self SETUPUI];
}

- (void)SETUPUI{
    self.dataSource = [NSMutableArray array];
    self.tableView.emptyDataSetSource = self;
    self.tableView.emptyDataSetDelegate = self;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    _tableView.separatorColor = [UIColor lightGrayColor];
    _tableView.separatorInset = UIEdgeInsetsMake(0, 13, 0, 0);
    _tableView.tableFooterView = [UIView new];
    _tableView.estimatedRowHeight = 44;
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"identifier"];
    _m = @"";
    for (NSDictionary *dic in _response[@"response"][@"purchaseOrder"][@"mixTypes"]) {
        _m = [NSString stringWithFormat:@"%@%@",_m,dic[@"message"]];
    }
    
    self.method.text = [NSString stringWithFormat:@"方法 : %@",_m];
    
    NSDictionary *dic = _response[@"response"][@"entryQueryResponse"][@"spMap"];
    for (NSString *key in dic.allKeys) {
        NSArray *array = dic[key];
       __block NSString *string = @"";
        for (NSString *str in array) {
            string = [NSString stringWithFormat:@"%@-%@",string,str];
        }
        string = [NSString stringWithFormat:@"%@: %@",key,string];
        NSLog(@"%@",string);
        [self.dataSource addObject:string];
    }
    
    [self.tableView reloadData];
    
    if (self.response) {
        NSData *data=[NSJSONSerialization dataWithJSONObject:_response options:NSJSONWritingPrettyPrinted error:nil];
        NSString *jsonStr=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
        self.textView.autoResizable = YES;
        self.textView.text = jsonStr;
    }
   self.navigationItem.title = @"单子详情";
}
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
{
    NSString *text = @"此单可能为预约单,等待庄家上传方案\n如果是篮球单子,结果请在下面接口里面找";
    
    NSDictionary *attributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:18.0f],
                                 NSForegroundColorAttributeName: [UIColor redColor]};
    
    return [[NSAttributedString alloc] initWithString:text attributes:attributes];
}
//- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state
//{
//    NSDictionary *attributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:17.0f],NSForegroundColorAttributeName: [UIColor cyanColor]};
//    
//    return [[NSAttributedString alloc] initWithString:@"刷新" attributes:attributes];
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark--UITableViewDelegate

//row height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 44;
}
//header height
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.01;
}
//footer height
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
// view--header
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
// view-footer
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    return [UIView new];
}
#pragma mark--UITableViewDataSource
//row 个数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataSource.count;
}

//section 个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
//自定义cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = self.dataSource[indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    return cell;
}

#pragma mark - 点击跳转方法

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
}

#pragma mark - lazy load




@end
